ccRV_CurrentTargetName = nil

function ccR_TrackTarget()
	if FireHack then
		if not frTargetTracking then frTargetTracking = CreateFrame("Frame") end;
		if frTargetTracking then
			if ccRS.CF_Target_Tracking then
				frTargetTracking:RegisterEvent("PLAYER_TARGET_CHANGED")
				frTargetTracking:SetScript("OnEvent", frTargetTracking_OnEvent)
			else
				frTargetTracking:SetScript("OnEvent", nil)
				PrintToChat("Target Tracking Disabled")
			end
		end
	end
end

function frTargetTracking_OnEvent(self, event, ...)
	if event == "PLAYER_TARGET_CHANGED" then
		if ccrTargetName() ~= nil 
		and ccrTargetName() ~= ccRV_CurrentTargetName then
			-- Stop Tracking old target
			if ccRV_CurrentTargetName ~= nil and GetTrackingState(ccRV_CurrentTargetName) == true then TrackByName(ccRV_CurrentTargetName) end;
			-- Update the var
			ccRV_CurrentTargetName = ccrTargetName()
			-- Track the new name
			if GetTrackingState(ccRV_CurrentTargetName) == false then TrackByName(ccRV_CurrentTargetName) end;
		end
	end
end
